import service from '@/utils/request'
import constant from '@/utils/constant'
import cache from '@/utils/cache'

export const useInfoApi = (id: number) => {
	return service.get('/project/info/' + id)
}
export const useStateCountApi = () => {
	return service.get('/project/process-states/statusStatistics')
}
export const useProjectCountApi = () => {
	return service.get('/project/info/countInfo')
}
export const useProjectTimeOutApi = () => {
	return service.get('/project/info/timeout')
}

export const useInfoSubmitApi = (dataForm: any) => {
	if (dataForm.id) {
		return service.put('/project/info', dataForm)
	} else {
		return service.post('/project/info', dataForm)
	}
}

export const getInfoByCode = (code: string) => {
	return service.get<ProjectInfo>('/project/info/code?code=' + code)
}
export const useInfoExportApi = () => {
	location.href = constant.apiUrl + '/project/info/export?access_token=' + cache.getToken()
}
